home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / p_man / cat3 / shmem_and.z / shmem_and
Encoding:
Text File  |  2002-10-03  |  15.6 KB  |  225 lines

  1.  
  2. SHMEM_AND(3)                                                   SHMEM_AND(3)
  3.  
  4.  
  5. NNNNAAAAMMMMEEEE
  6.      sssshhhhmmmmeeeemmmm____iiiinnnntttt____aaaannnndddd____ttttoooo____aaaallllllll, sssshhhhmmmmeeeemmmm____iiiinnnntttt4444____aaaannnndddd____ttttoooo____aaaallllllll, sssshhhhmmmmeeeemmmm____iiiinnnntttt8888____aaaannnndddd____ttttoooo____aaaallllllll,
  7.      sssshhhhmmmmeeeemmmm____lllloooonnnngggg____aaaannnndddd____ttttoooo____aaaallllllll, sssshhhhmmmmeeeemmmm____lllloooonnnngggglllloooonnnngggg____aaaannnndddd____ttttoooo____aaaallllllll,
  8.      sssshhhhmmmmeeeemmmm____sssshhhhoooorrrrtttt____aaaannnndddd____ttttoooo____aaaallllllll - Performs a logical AND function across a set
  9.      of processing elements (PEs)
  10.  
  11. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.      C or C++:
  13.  
  14.         ####iiiinnnncccclllluuuuddddeeee <<<<mmmmpppppppp////sssshhhhmmmmeeeemmmm....hhhh>>>>
  15.  
  16.         vvvvooooiiiidddd sssshhhhmmmmeeeemmmm____iiiinnnntttt____aaaannnndddd____ttttoooo____aaaallllllll((((iiiinnnntttt ****_t_a_r_g_e_t,,,, iiiinnnntttt ****_s_o_u_r_c_e,,,, iiiinnnntttt _n_r_e_d_u_c_e,,,,
  17.         iiiinnnntttt _P_E__s_t_a_r_t,,,, iiiinnnntttt _l_o_g_P_E__s_t_r_i_d_e,,,, iiiinnnntttt _P_E__s_i_z_e,,,, iiiinnnntttt ****_p_W_r_k,,,, lllloooonnnngggg
  18.         ****_p_S_y_n_c))));;;;
  19.  
  20.         vvvvooooiiiidddd sssshhhhmmmmeeeemmmm____lllloooonnnngggg____aaaannnndddd____ttttoooo____aaaallllllll((((lllloooonnnngggg ****_t_a_r_g_e_t,,,, lllloooonnnngggg ****_s_o_u_r_c_e,,,, iiiinnnntttt _n_r_e_d_u_c_e,,,,
  21.         iiiinnnntttt _P_E__s_t_a_r_t,,,, iiiinnnntttt _l_o_g_P_E__s_t_r_i_d_e,,,, iiiinnnntttt _P_E__s_i_z_e,,,, lllloooonnnngggg ****_p_W_r_k,,,, lllloooonnnngggg
  22.         ****_p_S_y_n_c))));;;;
  23.  
  24.         vvvvooooiiiidddd sssshhhhmmmmeeeemmmm____lllloooonnnngggglllloooonnnngggg____aaaannnndddd____ttttoooo____aaaallllllll((((lllloooonnnngggg lllloooonnnngggg ****_t_a_r_g_e_t,,,, lllloooonnnngggg lllloooonnnngggg
  25.         ****_s_o_u_r_c_e,,,, iiiinnnntttt _n_r_e_d_u_c_e,,,, iiiinnnntttt _P_E__s_t_a_r_t,,,, iiiinnnntttt _l_o_g_P_E__s_t_r_i_d_e,,,, iiiinnnntttt _P_E__s_i_z_e,,,,
  26.         lllloooonnnngggg lllloooonnnngggg ****_p_W_r_k,,,, lllloooonnnngggg ****_p_S_y_n_c))));;;;
  27.  
  28.         vvvvooooiiiidddd sssshhhhmmmmeeeemmmm____sssshhhhoooorrrrtttt____aaaannnndddd____ttttoooo____aaaallllllll((((sssshhhhoooorrrrtttt ****_t_a_r_g_e_t,,,, sssshhhhoooorrrrtttt ****_s_o_u_r_c_e,,,, iiiinnnntttt
  29.         _n_r_e_d_u_c_e,,,, iiiinnnntttt _P_E__s_t_a_r_t,,,, iiiinnnntttt _l_o_g_P_E__s_t_r_i_d_e,,,, iiiinnnntttt _P_E__s_i_z_e,,,, sssshhhhoooorrrrtttt ****_p_W_r_k,,,,
  30.         lllloooonnnngggg ****_p_S_y_n_c))));;;;
  31.  
  32.      Fortran:
  33.  
  34.         IIIINNNNCCCCLLLLUUUUDDDDEEEE """"mmmmpppppppp////sssshhhhmmmmeeeemmmm....ffffhhhh""""
  35.  
  36.         IIIINNNNTTTTEEEEGGGGEEEERRRR _p_S_y_n_c((((SSSSHHHHMMMMEEEEMMMM____RRRREEEEDDDDUUUUCCCCEEEE____SSSSYYYYNNNNCCCC____SSSSIIIIZZZZEEEE))))
  37.         IIIINNNNTTTTEEEEGGGGEEEERRRR _n_r_e_d_u_c_e,,,, _P_E__s_t_a_r_t,,,, _l_o_g_P_E__s_t_r_i_d_e,,,, _P_E__s_i_z_e
  38.  
  39.         CCCCAAAALLLLLLLL SSSSHHHHMMMMEEEEMMMM____IIIINNNNTTTT4444____AAAANNNNDDDD____TTTTOOOO____AAAALLLLLLLL((((_t_a_r_g_e_t,,,, _s_o_u_r_c_e,,,, _n_r_e_d_u_c_e,,,, _P_E__s_t_a_r_t,,,,
  40.         _l_o_g_P_E__s_t_r_i_d_e,,,, _P_E__s_i_z_e,,,, _p_W_r_k,,,, _p_S_y_n_c))))
  41.  
  42.         CCCCAAAALLLLLLLL SSSSHHHHMMMMEEEEMMMM____IIIINNNNTTTT8888____AAAANNNNDDDD____TTTTOOOO____AAAALLLLLLLL((((_t_a_r_g_e_t,,,, _s_o_u_r_c_e,,,, _n_r_e_d_u_c_e,,,, _P_E__s_t_a_r_t,,,,
  43.         _l_o_g_P_E__s_t_r_i_d_e,,,, _P_E__s_i_z_e,,,, _p_W_r_k,,,, _p_S_y_n_c))))
  44.  
  45. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  46.      The shared memory (SHMEM) reduction routines compute one or more
  47.      reductions across symmetric arrays on multiple virtual PEs.  A
  48.      reduction performs an associative binary operation across a set of
  49.      values.  For a list of other SHMEM reduction routines, see
  50.      iiiinnnnttttrrrroooo____sssshhhhmmmmeeeemmmm(3).
  51.  
  52.      The _n_r_e_d_u_c_e argument determines the number of separate reductions to
  53.      perform.  The source array on all PEs in the active set provides one
  54.      element for each reduction.  The results of the reductions are placed
  55.      in the target array on all PEs in the active set.  The active set is
  56.      defined by the _P_E__s_t_a_r_t, _l_o_g_P_E__s_t_r_i_d_e, _P_E__s_i_z_e triplet.
  57.  
  58.      The _s_o_u_r_c_e and _t_a_r_g_e_t arrays may be the same array, but they may not
  59.      be overlapping arrays.
  60.  
  61.      As with all SHMEM collective routines, each of these routines assumes
  62.      that only PEs in the active set call the routine.  If a PE not in the
  63.      active set calls a SHMEM collective routine, undefined behavior
  64.      results.
  65.  
  66.      The arguments are as follows:
  67.  
  68.      _t_a_r_g_e_t       A symmetric array, of length _n_r_e_d_u_c_e elements, to receive
  69.                   the result of the reduction operations.
  70.  
  71.                   The data type of _t_a_r_g_e_t varies with the version of the
  72.                   reduction routine being called.  When calling from C/C++,
  73.                   refer to the SYNOPSIS section for data type information.
  74.                   When calling from Fortran, the _t_a_r_g_e_t date types are as
  75.                   follows:
  76.  
  77.                   RRRRoooouuuuttttiiiinnnneeee                       DDDDaaaattttaaaa TTTTyyyyppppeeee
  78.  
  79.                   sssshhhhmmmmeeeemmmm____iiiinnnntttt8888____aaaannnndddd____ttttoooo____aaaallllllll         Integer, with an element
  80.                                                 size of 8 bytes
  81.  
  82.                   sssshhhhmmmmeeeemmmm____iiiinnnntttt4444____aaaannnndddd____ttttoooo____aaaallllllll         Integer, with an element
  83.                                                 size of 4 bytes
  84.  
  85.      _s_o_u_r_c_e       A symmetric array, of length _n_r_e_d_u_c_e elements, that
  86.                   contains one element for each separate reduction
  87.                   operation.  The _s_o_u_r_c_e argument must have the same data
  88.                   type as _t_a_r_g_e_t.
  89.  
  90.      _n_r_e_d_u_c_e      The number of elements in the _t_a_r_g_e_t and _s_o_u_r_c_e arrays.
  91.                   _n_r_e_d_u_c_e must be of type integer.  If you are using
  92.                   Fortran, it must be a default integer value.
  93.  
  94.      _P_E__s_t_a_r_t     The lowest virtual PE number of the active set of PEs.
  95.                   _P_E__s_t_a_r_t must be of type integer.  If you are using
  96.                   Fortran, it must be a default integer value.
  97.  
  98.      _l_o_g_P_E__s_t_r_i_d_e The log (base 2) of the stride between consecutive
  99.                   virtual PE numbers in the active set.  _l_o_g_P_E__s_t_r_i_d_e must
  100.                   be of type integer.  If you are using Fortran, it must be
  101.                   a default integer value.
  102.  
  103.      _P_E__s_i_z_e      The number of PEs in the active set.  _P_E__s_i_z_e must be of
  104.                   type integer.  If you are using Fortran, it must be a
  105.                   default integer value.
  106.  
  107.      _p_W_r_k         A symmetric work array.  The _p_W_r_k argument must have the
  108.                   same data type as _t_a_r_g_e_t.
  109.  
  110.                   In C/C++, this contains
  111.                   mmmmaaaaxxxx((((_n_r_e_d_u_c_e////2222 ++++ 1111,,,, ____SSSSHHHHMMMMEEEEMMMM____RRRREEEEDDDDUUUUCCCCEEEE____MMMMIIIINNNN____WWWWRRRRKKKKDDDDAAAATTTTAAAA____SSSSIIIIZZZZEEEE))))
  112.                   elements.
  113.  
  114.                   In Fortran, this contains
  115.                   mmmmaaaaxxxx((((_n_r_e_d_u_c_e////2222 ++++ 1111,,,, SSSSHHHHMMMMEEEEMMMM____RRRREEEEDDDDUUUUCCCCEEEE____MMMMIIIINNNN____WWWWRRRRKKKKDDDDAAAATTTTAAAA____SSSSIIIIZZZZEEEE))))
  116.                   elements.
  117.  
  118.      _p_S_y_n_c        A symmetric work array.
  119.  
  120.                   In C/C++, _p_S_y_n_c must be of type lllloooonnnngggg and size
  121.                   ____SSSSHHHHMMMMEEEEMMMM____RRRREEEEDDDDUUUUCCCCEEEE____SSSSYYYYNNNNCCCC____SSSSIIIIZZZZEEEE.
  122.  
  123.                   In Fortran, _p_S_y_n_c must be of type integer and size
  124.                   SSSSHHHHMMMMEEEEMMMM____RRRREEEEDDDDUUUUCCCCEEEE____SSSSYYYYNNNNCCCC____SSSSIIIIZZZZEEEE.  If you are using Fortran, it
  125.                   must be a default integer value.
  126.  
  127.                   Every element of this array must be initialized with the
  128.                   value ____SSSSHHHHMMMMEEEEMMMM____SSSSYYYYNNNNCCCC____VVVVAAAALLLLUUUUEEEE (in C/C++) or SSSSHHHHMMMMEEEEMMMM____SSSSYYYYNNNNCCCC____VVVVAAAALLLLUUUUEEEE
  129.                   (in Fortran) before any of the PEs in the active set
  130.                   enter the reduction routine.
  131.  
  132.      The values of arguments _n_r_e_d_u_c_e, _P_E__s_t_a_r_t, _l_o_g_P_E__s_t_r_i_d_e, and _P_E__s_i_z_e
  133.      must be equal on all PEs in the active set.  The same _t_a_r_g_e_t and
  134.      _s_o_u_r_c_e arrays, and the same _p_W_r_k and _p_S_y_n_c work arrays, must be passed
  135.      to all PEs in the active set.
  136.  
  137.      Before any PE calls a reduction routine, you must ensure that the
  138.      following conditions exist (synchronization via a barrier or some
  139.      other method is often needed to ensure this):
  140.  
  141.      * The _p_W_r_k and _p_S_y_n_c arrays on all PEs in the active set are not still
  142.        in use from a prior call to a collective SHMEM routine.
  143.  
  144.      * The _t_a_r_g_e_t array on all PEs in the active set is ready to accept the
  145.        results of the reduction.
  146.  
  147.      Upon return from a reduction routine, the following are true for the
  148.      local PE:
  149.  
  150.      * The _t_a_r_g_e_t array is updated.
  151.  
  152.      * The data cache region mapped to _t_a_r_g_e_t is coherent.
  153.  
  154.      * The values in the _p_S_y_n_c array are restored to the original values.
  155.  
  156. NNNNOOOOTTTTEEEESSSS
  157.      The terms _c_o_l_l_e_c_t_i_v_e, _s_y_m_m_e_t_r_i_c, and _c_a_c_h_e _a_l_i_g_n_e_d are defined in
  158.      iiiinnnnttttrrrroooo____sssshhhhmmmmeeeemmmm(3).
  159.  
  160.      All SHMEM reduction routines reset the values in _p_S_y_n_c before they
  161.      return, so a particular _p_S_y_n_c buffer need only be initialized the
  162.      first time it is used.
  163.  
  164.      You must ensure that the _p_S_y_n_c array is not being updated on any PE in
  165.      the active set while any of the PEs participate in processing of a
  166.      SHMEM reduction routine.  Be careful to avoid the following
  167.      situations:
  168.  
  169.      * If the _p_S_y_n_c array is initialized at run time, some type of
  170.        synchronization is needed to ensure that all PEs in the working set
  171.        have initialized _p_S_y_n_c before any of them enter a SHMEM routine
  172.        called with the _p_S_y_n_c synchronization array.
  173.  
  174.      * A _p_S_y_n_c or _p_W_r_k array can be reused in a subsequent reduction
  175.        routine call only if none of the PEs in the active set are still
  176.        processing a prior reduction routine call that used the same _p_S_y_n_c
  177.        or _p_W_r_k arrays.  In general, this can be assured only by doing some
  178.        type of synchronization.  However, in the special case of reduction
  179.        routines being called with the same active set, you can allocate two
  180.        _p_S_y_n_c and _p_W_r_k arrays and alternate between them on successive
  181.        calls.
  182.  
  183. EEEEXXXXAAAAMMMMPPPPLLLLEEEESSSS
  184.      Example 1:  This Fortran example statically initializes the _p_S_y_n_c
  185.      array and finds the logical AND of the integer variable FFFFOOOOOOOO across all
  186.      even PEs.
  187.  
  188.            INCLUDE "mpp/shmem.fh"
  189.  
  190.            INTEGER PSYNC(SHMEM_REDUCE_SYNC_SIZE)
  191.            DATA PSYNC /SHMEM_REDUCE_SYNC_SIZE*SHMEM_SYNC_VALUE/
  192.            PARAMETER (NR=1)
  193.            REAL PWRK(MAX(NR/2+1,SHMEM_REDUCE_MIN_WRKDATA_SIZE))
  194.            INTEGER FOO, FOOAND
  195.            COMMON /COM/ FOO, FOOAND, PWRK
  196.            INTRINSIC MY_PE
  197.  
  198.            IF ( MOD(MY_PE(),2) .EQ. 0) THEN
  199.               CALL SHMEM_INT8_AND_TO_ALL(FOOAND, FOO, NR, 0, 1, N$PES/2,
  200.           &      PWRK, PSYNC)
  201.               PRINT*,'Result on PE ',MY_PE(),' is ',FOOAND
  202.            ENDIF
  203.  
  204.      Example 2:  Consider the following C call:
  205.  
  206.           shmem_int_and_to_all( target, source, 3, 0, 0, 8, pwrk, psync );
  207.  
  208.      The preceding call is more efficient, but semantically equivalent to,
  209.      the combination of the following calls:
  210.  
  211.           shmem_int_and_to_all(&(target[0]), &(source[0]), 1, 0, 0, 8,
  212.              pwrk1, psync1);
  213.           shmem_int_and_to_all(&(target[1]), &(source[1]), 1, 0, 0, 8,
  214.              pwrk2, psync2);
  215.           shmem_int_and_to_all(&(target[2]), &(source[2]), 1, 0, 0, 8,
  216.              pwrk1, psync1);
  217.  
  218.      Note that two sets of _p_W_r_k and _p_S_y_n_c arrays are used alternately
  219.      because no synchronization is done between calls.
  220.  
  221. SSSSEEEEEEEE AAAALLLLSSSSOOOO
  222.      ffff99990000(1), ffff99990000(1M), iiiinnnnttttrrrroooo____sssshhhhmmmmeeeemmmm(3)
  223.  
  224.      _M_e_s_s_a_g_e _P_a_s_s_i_n_g _T_o_o_l_k_i_t: _M_P_I _P_r_o_g_r_a_m_m_e_r'_s _M_a_n_u_a_l
  225.